﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" x:Class="Wulong.Phone.Qiushi.Views.CommentsView" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    Style="{StaticResource TransitionPageStyle}">

    <phone:PhoneApplicationPage.Resources>
        
        <Style x:Key="CommentsListBoxStyle" TargetType="ListBox">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBox">
                        <ScrollViewer x:Name="ScrollViewer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" Padding="{TemplateBinding Padding}">
                            <StackPanel>
                                <Border Background="{StaticResource PhoneChromeBrush}">
                                    <StackPanel Visibility="{Binding IsPostVisible, 
                            Converter={StaticResource BooleanToVisibilityConverter}}">
                                        <TextBlock Text="{Binding QiushiContent}" TextWrapping="Wrap" Width="440" Style="{StaticResource PhoneTextNormalStyle}"/>
                                        <Image Source="{Binding ImageUrl}"/>
                                    </StackPanel>                  	
                                </Border>
                                
                                <ItemsPresenter/>
                            </StackPanel>
                        </ScrollViewer>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <adduplex:AdControl xmlns:adduplex="clr-namespace:AdDuplex;assembly=AdDuplex.AdControl.Silverlight"
                            Grid.Row="0" 
                            AppId="3423" 
                            Background="Transparent"
                            BackgroundOpacity="0.5"
                            />
        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="1" Margin="12,17,0,28" Orientation="Vertical">
            <TextBlock x:Name="ApplicationTitle" Text="{Binding Path=AppI18N.App_Title, Source={StaticResource ls}}" Style="{StaticResource PhoneTextSmallStyle}" />
            <TextBlock x:Name="PageTitle" Text="{Binding Path=AppI18N.V_Comments_Title, Source={StaticResource ls}}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle2Style}"/>
            <Button x:Name="TogglePostVisibility" Content="{Binding PostButtonLabel}" BorderBrush="Transparent" BorderThickness="0">
            </Button>
            
        </StackPanel>
        <ListBox Grid.Row="2" x:Name="Comments" Style="{StaticResource CommentsListBoxStyle}" >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border Padding="5" Width="440" BorderBrush="Chocolate" >
                        <StackPanel>
                            <StackPanel VerticalAlignment="Top" HorizontalAlignment="Left" Orientation="Horizontal">
                                <TextBlock Text="{Binding Floor}" Padding="4" Style="{StaticResource PhoneTextAccentStyle}"/>
                                <TextBlock Text="{Binding Author}" FontStyle="Italic" Style="{StaticResource PhoneTextAccentStyle}" />                   
                            </StackPanel>
                        <TextBlock Text="{Binding Body}" VerticalAlignment="Top" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" />
                        <toolkit:Separator BorderBrush="{StaticResource PhoneChromeBrush}" BorderThickness="1" Width="440" />
                    </StackPanel>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        
        <!--TitlePanel contains the name of the application and page title-->
        
        <!--Loading bar and text-->
        <Grid Grid.Row="1"
                      Visibility="{Binding IsBusy, 
                            Converter={StaticResource BooleanToVisibilityConverter}}">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <TextBlock Text="{Binding Path=AppI18N.App_Loading, Source={StaticResource ls}}" 
                               Style="{StaticResource LoadingStyle}"/>
            <toolkit:PerformanceProgressBar IsIndeterminate="{Binding IsBusy}"
                                 VerticalAlignment="Top" 
                                 IsTabStop="True"
                                 Grid.Row="1" />
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>
